﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="khuyenmai.aspx.cs" Inherits="Admin_khuyenmai" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="../CSS/style.css" rel="stylesheet" type="text/css" />
    <link href="../CSS/border-radius.css" rel="stylesheet" type="text/css" />
    <link href="../CSS/jscal2.css" rel="stylesheet" type="text/css" />
    <script src="../js/jscal2.js" type="text/javascript"></script>
    <script src="../js/lang/vi.js" type="text/javascript"></script>
    <style type="text/css">
        .style1
        {
            width: 35%;
        }
        .style2
        {
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <table cellpadding="4" cellspacing="0" style="width: 100%; text-align: left;">
            <tr>
                <td class="head" colspan="4">
                    Cập nhật danh sách khuyến mãi</td>
            </tr>
            <tr>
                <td class="style1" width="15%">
                    Loại SP</td>
                <td width="35%" class="style2">
                    <asp:DropDownList ID="drdloaiSP" runat="server" AutoPostBack="True" 
                        DataSourceID="danhsachloaiSP" DataTextField="tenloai" DataValueField="id_row">
                    </asp:DropDownList>
                </td>
                <td width="15%">
                    Sản phẩm</td>
                <td width="35%">
                    <asp:DropDownList ID="drddanhsachSP" runat="server" DataSourceID="danhsachSP" 
                        DataTextField="tensp" DataValueField="id_row">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td class="style1">
                    Thời gian bắt đầu</td>
                <td class="style2">
                    <asp:TextBox ID="txtthoigianbatdau" runat="server" Width="38%"></asp:TextBox>
                    <a id="Lnk_ngaybatdau" class="icsl" href="javascript:;">&nbsp;</a>
                    <script type="text/javascript">
                        Calendar.setup({
                            inputField: "<%= txtthoigianbatdau.ClientID %>",
                            dateFormat: "%d/%m/%Y",
                            trigger: "Lnk_ngaybatdau",
                            titleFormat: "%B, %Y",
                            onSelect: function () { this.hide() }
                        });</script></td>
                <td>
                        Thời gian kết thúc</td>
                <td>
                    <asp:TextBox ID="txtthoigianketthuc" runat="server" Width="70%" ></asp:TextBox>
                    <a id="Lnk_ngayketthuc" class="icsl" href="javascript:;">&nbsp;</a>
                    <script type="text/javascript">
                        Calendar.setup({
                            inputField: "<%= txtthoigianketthuc.ClientID %>",
                            dateFormat: "%d/%m/%Y",
                            trigger: "Lnk_ngayketthuc",
                            titleFormat: "%B, %Y",
                            onSelect: function () { this.hide() }
                        });</script>
                    </td>
            </tr>
            <tr>
                    <td class="style1">
                    Chi tiết khuyến mãi</td>
                <td class="style2" colspan="3">
                    <asp:TextBox ID="txtchitietkhuyenmai" runat="server" Width="95%" 
                        TextMode="MultiLine"></asp:TextBox>
                    </td>
            </tr>
            <tr>
                <td class="style1">
                    &nbsp;</td>
                <td class="style2">
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
                <td>
                    <asp:Button ID="btnthem" runat="server" CssClass="ica" Text="Thêm" 
                        onclick="btnthem_Click" ValidationGroup="reg" />
                    <asp:Button ID="btnboqua" runat="server" CssClass="icc" Text="Bỏ qua" 
                        onclick="btnboqua_Click" />
                </td>
            </tr>
            <tr>
                <td colspan="4" class="header">
                    &nbsp;</td>
            </tr>
            <tr>
                <td colspan="4">
                    <asp:GridView ID="grvds" runat="server" AutoGenerateColumns="False" 
                        meta:resourcekey="grvdsResource1" Width="100%" 
                        DataSourceID="danhsachkhuyenmai" style="margin-top: 1px">
                        <Columns>
                            <asp:TemplateField HeaderText="STT" meta:resourcekey="TemplateFieldResource1">
                                <ItemStyle HorizontalAlign="Center" Width="3%" />
                                <ItemTemplate>
                                    <%#Container.DataItemIndex+1 %>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Loai SP">
                                <ItemTemplate>
                                    <asp:Label ID="lbmasp" runat="server" Text='<%# Eval("tenloai") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Tên SP" 
                                meta:resourcekey="TemplateFieldResource2">
                                <ItemTemplate>
                                    <asp:Label ID="lbten" runat="server" meta:resourcekey="lbtenResource1" 
                                        Text='<%# Eval("Tensp") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Thời gian bắt đầu">
                                <ItemTemplate>
                                    <asp:Label ID="lbngayBD" runat="server" 
                                        Text='<%# Eval("ngaybatdau", "{0:dd/MM/yyyy}") %>'></asp:Label>
                                </ItemTemplate>
                                <ItemStyle Width="7%" />
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Thời gian kết thúc">
                                <ItemTemplate>
                                    <asp:Label ID="lbngayKt" runat="server" 
                                        Text='<%# Eval("ngayketthuc","{0:dd/MM/yyyy}") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Chi tiết khuyến mãi">
                                <ItemTemplate>
                                    <asp:Label ID="lbchitietKM" runat="server" 
                                        Text='<%# Eval("chitietkhuyenmai") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:ImageButton ID="imgsua" runat="server" 
                                        CommandArgument='<%# Eval("id_row") %>' 
                                        ImageUrl="~/images/Testing/pencil_16.png" ToolTip="sửa" 
                                        onclick="imgsua_Click" />
                                    <asp:ImageButton ID="imgxoa" runat="server" 
                                        CommandArgument='<%# Eval("id_row") %>' 
                                        ImageUrl="~/images/Testing/delete_16.png" 
                                        onclientclick="return confirm('Bạn có chắc muốn xóa')" 
                                        onclick="imgxoa_Click" />
                                    <asp:Label ID="lbidSP" runat="server" Text='<%# Eval("id_SP") %>' 
                                        Visible="False"></asp:Label>
                                    <asp:Label ID="lbidloaiSP" runat="server" Text='<%# Eval("id_loaiSP") %>' 
                                        Visible="False"></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>
                    <asp:SqlDataSource ID="danhsachkhuyenmai" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                        
                        SelectCommand="SELECT Khuyenmai.id_sp, Khuyenmai.id_row, Khuyenmai.ngaybatdau, Khuyenmai.ngayketthuc, Khuyenmai.Chitietkhuyenmai, SanPham.id_loaisp, SanPham.tensp, Loaisanpham.tenloai, SanPham.masp FROM Khuyenmai INNER JOIN SanPham ON Khuyenmai.id_sp = SanPham.id_row INNER JOIN Loaisanpham ON SanPham.id_loaisp = Loaisanpham.id_row">
                    </asp:SqlDataSource>
                    <asp:SqlDataSource ID="dsnhanvien" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                        SelectCommand="SELECT * FROM [Khuyenmai]"></asp:SqlDataSource>
                </td>
            </tr>
        </table>
    
    </div>
                    <asp:SqlDataSource ID="danhsachloaiSP" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                        SelectCommand="SELECT * FROM [Loaisanpham]"></asp:SqlDataSource>
                    <asp:SqlDataSource ID="danhsachSP" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                        SelectCommand="SELECT [id_row], [tensp] FROM [SanPham] WHERE ([id_loaisp] = @id_loaisp)">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="drdloaiSP" Name="id_loaisp" 
                                PropertyName="SelectedValue" Type="Decimal" />
                        </SelectParameters>
                    </asp:SqlDataSource>
    <asp:Label ID="lbid" runat="server"></asp:Label>
    </form>
</body>
</html>
